// import * as Mock from 'mockjs'
// const p = Mock.mock({
//   'list|1-20': [
//     {
//       'studentId|+1': 1,
//       name: '@cname',
//       school: '云龙学校',
//       grade: '一年级',
//       'gender|0-1': 0,
//       class: '0班',
//       rank: {
//         rank1: [
//           {
//             self: 'A',
//             guardian: 'A',
//             teacher: 'A',
//             mutual: 'A'
//           }
//         ]
//       }
//     }
//   ]
// })
const student = {
  one: [
    {
      studentId: 1,
      name: '王丽1',
      school: '云龙学校',
      schoolId: 1,
      grade: '一年级',
      gender: 0,
      class: '0班',

      self: 'A',
      guardian: 'D',
      teacher: 'A',
      mutual: 'A'
    },
    {
      studentId: 2,
      name: '姜娜',
      school: '云龙学校',
      schoolId: 1,
      grade: '二年级',
      gender: 0,
      class: '0班',

      self: 'A',
      guardian: 'A',
      teacher: 'A',
      mutual: 'D'
    },
    {
      studentId: 3,
      name: '彭秀兰',
      school: '云龙学校',
      schoolId: 1,
      grade: '二年级',
      gender: 1,
      class: '0班',

      self: 'A',
      guardian: 'A',
      teacher: 'A',
      mutual: 'A'
    },
    {
      studentId: 4,
      name: '雷霞',
      school: '技术学校',
      schoolId: 5,
      grade: '一年级',
      gender: 1,
      class: '0班',

      self: 'A',
      guardian: 'A',
      teacher: 'A',
      mutual: 'A'
    },
    {
      studentId: 5,
      name: '贺静',
      school: '云龙学校',
      schoolId: 1,
      grade: '一年级',
      gender: 0,
      class: '0班',

      self: 'A',
      guardian: 'A',
      teacher: 'A',
      mutual: 'A'
    },
    {
      studentId: 6,
      name: '苏磊',
      school: '技术学校',
      schoolId: 5,
      grade: '一年级',
      gender: 1,
      class: '0班',

      self: 'A',
      guardian: 'A',
      teacher: 'A',
      mutual: 'A'
    },
    {
      studentId: 7,
      name: '刘涛',
      school: '云龙学校',
      schoolId: 1,
      grade: '一年级',
      gender: 0,
      class: '0班',

      self: 'A',
      guardian: 'A',
      teacher: 'A',
      mutual: 'A'
    },
    {
      studentId: 8,
      name: '康明',
      school: '云龙学校',
      schoolId: 1,
      grade: '一年级',
      gender: 0,
      class: '0班',

      self: 'A',
      guardian: 'A',
      teacher: 'A',
      mutual: 'A'
    },
    {
      studentId: 9,
      name: '李明',
      school: '云龙学校',
      schoolId: 1,
      grade: '一年级',
      gender: 0,
      class: '0班',

      self: 'A',
      guardian: 'A',
      teacher: 'A',
      mutual: 'A'
    },
    {
      studentId: 10,
      name: '谢娟',
      school: '云龙学校',
      schoolId: 1,
      grade: '一年级',
      gender: 0,
      class: '0班',

      self: 'A',
      guardian: 'A',
      teacher: 'A',
      mutual: 'A'
    },
    {
      studentId: 11,
      name: '白静',
      school: '云龙学校',
      schoolId: 1,
      grade: '一年级',
      gender: 0,
      class: '0班',

      self: 'A',
      guardian: 'A',
      teacher: 'A',
      mutual: 'A'
    },
    {
      studentId: 12,
      name: '龚明',
      school: '云龙学校',
      schoolId: 1,
      grade: '一年级',
      gender: 0,
      class: '0班',

      self: 'A',
      guardian: 'A',
      teacher: 'A',
      mutual: 'A'
    },
    {
      studentId: 13,
      name: '顾敏',
      school: '云龙学校',
      schoolId: 1,
      grade: '一年级',
      gender: 0,
      class: '0班',

      self: 'A',
      guardian: 'A',
      teacher: 'A',
      mutual: 'A'
    },
    {
      studentId: 14,
      name: '丁明',
      school: '云龙学校',
      schoolId: 1,
      grade: '一年级',
      gender: 0,
      class: '0班',

      self: 'A',
      guardian: 'A',
      teacher: 'A',
      mutual: 'A'
    }
  ],
  two: [
    {
      studentId: 1,
      name: '王丽2',
      school: '云龙学校',
      schoolId: 1,
      grade: '一年级',
      gender: 0,
      class: '0班',

      self: 'A',
      guardian: 'A',
      teacher: 'A',
      mutual: 'A'
    },
    {
      studentId: 2,
      name: '姜娜',
      school: '云龙学校',
      schoolId: 1,
      grade: '一年级',
      gender: 0,
      class: '0班',

      self: 'A',
      guardian: 'A',
      teacher: 'A',
      mutual: 'A'
    },
    {
      studentId: 3,
      name: '彭秀兰',
      school: '云龙学校',
      schoolId: 1,
      grade: '一年级',
      gender: 1,
      class: '0班',

      self: 'A',
      guardian: 'A',
      teacher: 'A',
      mutual: 'A'
    },
    {
      studentId: 4,
      name: '雷霞',
      school: '云龙学校',
      schoolId: 1,
      grade: '一年级',
      gender: 1,
      class: '0班',

      self: 'A',
      guardian: 'A',
      teacher: 'A',
      mutual: 'A'
    },
    {
      studentId: 5,
      name: '贺静',
      school: '云龙学校',
      schoolId: 1,
      grade: '一年级',
      gender: 0,
      class: '0班',

      self: 'A',
      guardian: 'A',
      teacher: 'A',
      mutual: 'A'
    },
    {
      studentId: 6,
      name: '苏磊',
      school: '云龙学校',
      schoolId: 1,
      grade: '一年级',
      gender: 1,
      class: '0班',

      self: 'A',
      guardian: 'A',
      teacher: 'A',
      mutual: 'A'
    },
    {
      studentId: 7,
      name: '刘涛',
      school: '云龙学校',
      schoolId: 1,
      grade: '一年级',
      gender: 0,
      class: '0班',

      self: 'A',
      guardian: 'A',
      teacher: 'A',
      mutual: 'A'
    },
    {
      studentId: 8,
      name: '康明',
      school: '云龙学校',
      schoolId: 1,
      grade: '一年级',
      gender: 0,
      class: '0班',

      self: 'A',
      guardian: 'A',
      teacher: 'A',
      mutual: 'A'
    },
    {
      studentId: 9,
      name: '李明',
      school: '云龙学校',
      schoolId: 1,
      grade: '一年级',
      gender: 0,
      class: '0班',

      self: 'A',
      guardian: 'A',
      teacher: 'A',
      mutual: 'A'
    },
    {
      studentId: 10,
      name: '谢娟',
      school: '云龙学校',
      schoolId: 1,
      grade: '一年级',
      gender: 0,
      class: '0班',

      self: 'A',
      guardian: 'A',
      teacher: 'A',
      mutual: 'A'
    },
    {
      studentId: 11,
      name: '白静',
      school: '云龙学校',
      schoolId: 1,
      grade: '一年级',
      gender: 0,
      class: '0班',

      self: 'A',
      guardian: 'A',
      teacher: 'A',
      mutual: 'A'
    },
    {
      studentId: 12,
      name: '龚明',
      school: '云龙学校',
      schoolId: 1,
      grade: '一年级',
      gender: 0,
      class: '0班',

      self: 'A',
      guardian: 'A',
      teacher: 'A',
      mutual: 'A'
    },
    {
      studentId: 13,
      name: '顾敏',
      school: '云龙学校',
      schoolId: 1,
      grade: '一年级',
      gender: 0,
      class: '0班',

      self: 'A',
      guardian: 'A',
      teacher: 'A',
      mutual: 'A'
    },
    {
      studentId: 14,
      name: '丁明',
      school: '云龙学校',
      schoolId: 1,
      grade: '一年级',
      gender: 0,
      class: '0班',

      self: 'A',
      guardian: 'A',
      teacher: 'A',
      mutual: 'A'
    }
  ]
}

// console.log(p)
export default [
  {
    url: '/school/studentList',
    method: 'get',
    response: (params) => {
      function paging(current: number, size: number, term1: string, schoolId: number) {
        if (term1 == '2022-one') {
          const result: any[] = []
          for (let i = 0; i < student.one.length; i++) {
            if (student.one[i].schoolId == schoolId) {
              result.push(student.one[i])
            }
          }

          const total = result.length
          const current1 = current
          const size1 = size
          const right = size1 * current1
          const left = (current - 1) * size
          const page = result.slice(left, right)
          return {
            code: '0000',
            total,
            page
          }
        } else if (term1 == '2022-two') {
          const result: any[] = []
          for (let i = 0; i < student.two.length; i++) {
            if (student.two[i].schoolId == schoolId) {
              result.push(student.two[i])
            }
          }
          const total = result.length
          const current1 = current
          const size1 = size
          const right = size1 * current1
          const left = (current - 1) * size
          const page = result.slice(left, right)
          return {
            code: '0000',
            total,
            page
          }
        }
      }
      const t = params.query.term
      if (t == '2022-one') {
        const current = params.query.current
        const size = params.query.size
        const schoolId = params.query.schoolId
        const result = paging(current, size, '2022-one', schoolId)
        return {
          code: '0000',
          result
        }
      } else if (t == '2022-two') {
        const schoolId = params.query.schoolId
        const current = params.query.current
        const size = params.query.size
        const result = paging(current, size, '2022-two', schoolId)
        return {
          code: '0000',
          result
        }
      } else {
        return {
          code: '0000',
          data: student
        }
      }
    }
  }
]
